/**
 * @file Token.cpp
 * @author  Aljosa Osep <aljosa.osep@gmail.com, Marjan Mernik, Vilijem Zumer>
 * @version 1.0
 *
 * @section LICENSE
 *
 * Redistribution and use in source and binary forms, with or without modification, are
 * permitted provided that the following conditions are met:

 *  1. Redistributions of source code must retain the above copyright notice, this list of
 *    conditions and the following disclaimer.

 *  2. Redistributions in binary form must reproduce the above copyright notice, this list
 *     of conditions and the following disclaimer in the documentation and/or other materials
 *     provided with the distribution.

 * THIS SOFTWARE IS PROVIDED BY <Aljosa Osep> ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <Aljosa Osep>> OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 * The views and conclusions contained in the software and documentation are those of the
 * authors and should not be interpreted as representing official policies, either expressed
 * or implied, of <Aljosa Osep>.
 *
 * @section DESCRIPTION
 *
 * Token implementation
 * Based on code sample from FERI lessons
 * Original authors: Marjan Mernik, Vilijem Zumer. Thanks!
 */

#include "token.h"

/**
 * Constuctor
 *
 * Constructs one token
 *
 * @param  Lexem value (string)
 * @param  Column (int)
 * @param  Row (int)
 * @param  Lexem type (int)
 * @param End of file (bool)
 */
Token::Token(const string &lexem, int column, int row, int lex_type, bool eof)
        : lexem(lexem), column(column), row(row), lex_type(lex_type), eof(eof)
{ 
    //
}

/**
 * Default Constuctor
 *
 * Constructs one empty token
 *
 */
Token::Token() : lexem("")
{ 
    //
}

/**
 * End of file
 *
 * Returns boolean value indicating wheter end of file has been reached or not
 *
 * @return End of file status (bool)
 */
bool Token::getEof()
{
    return this->eof;
}

/**
 * Token type
 *
 * Returns index representing token's type
 *
 * @return Token type (int)
 */
int Token::getType()
{
    return this->lex_type;
}

/**
 * Token lexem (string value)
 *
 * Returns token's string
 *
 * @return Lexem (string)
 */
string Token::getLexem()
{
    return this->lexem;
}

/**
 * Prints token info
 */
string Token::getTokenInfo()
{
    string tip;
    switch(this->lex_type)
    {
            case LEXERROR:
            tip = "lexical error";
            break;

            case IGNORE:
            tip = "empty character";
            break;

            case NUMBER:
            tip = "number";
            break;

            case OPERATOR:
            tip = "operator";
            break;

            case SEPARATOR:
            tip = "separator";
            break;

            case IDENTIFICATOR:
            tip = "identificator";
            break;

            case STRING:
            tip = "string";
            break;
    }

    return lexem + " - row: " + toString(column) + " column: " +  toString(row) + " type: " + tip;
}



